package com.fan.analysis.module.analysis.warning.controller;


import com.fan.analysis.common.constant.ResponseCodeConst;
import com.fan.analysis.common.domain.ResponseDTO;
import com.fan.analysis.module.analysis.group.domain.vo.GroupVo;
import com.fan.analysis.module.analysis.warning.domain.vo.DefaultUserVo;
import com.fan.analysis.module.analysis.warning.domain.vo.SensitiveUserVo;
import com.fan.analysis.module.analysis.warning.service.UserWarningService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户行为预警
 *
 * @author fan
 * @date 2021/10/08 16:30
 **/
@Slf4j
@RestController
public class UserWarningController {

    private final UserWarningService userWarningService;

    @Autowired
    public UserWarningController(UserWarningService userWarningService) {
        this.userWarningService = userWarningService;
    }

    @ApiOperation("数据分析-用户行为预警 @author fan")
    @PostMapping(value = "/analysis/get_sensitive_user")
    public ResponseDTO<SensitiveUserVo> getSensitiveUser() {

        log.info("数据分析-用户行为预警");
        try {
            return userWarningService.getSensitiveUser();
        } catch (Exception exception) {
            log.info(exception.getMessage());
            return ResponseDTO.wrap(ResponseCodeConst.SYSTEM_ERROR);
        }
    }

    @ApiOperation("数据分析-用户行为预警 @author fan")
    @PostMapping(value = "/analysis/get_this_phone_num_info")
    public ResponseDTO<DefaultUserVo> getThisPhoneNumInfo(@RequestParam("phone_num") String phoneNum) {

        log.info("数据分析-根据手机号搜索自己信息和常用联系人信息");
        try {
            return userWarningService.getThisPhoneNumInfo(phoneNum);
        } catch (Exception exception) {
            log.info(exception.getMessage());
            return ResponseDTO.wrap(ResponseCodeConst.SYSTEM_ERROR);
        }
    }
}
